package com.example.simin_manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.simin_manage.entity.OrderRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * @description:
 * @author: panpan
 * @time: 2025/9/14
 */
@Mapper
public interface OrderMapper extends BaseMapper<OrderRecord> {
    @Select("SELECT * FROM order_record WHERE user_id = #{userId} AND record_date = #{recordDate}")
    OrderRecord findByUserAndDate(@Param("userId") Long userId,
                                  @Param("recordDate") LocalDate recordDate);

    @Select("SELECT * FROM order_record WHERE user_id=#{userId} AND record_date BETWEEN #{startDate} AND #{endDate} ORDER BY record_date")
    List<OrderRecord> findByUserAndPeriod(@Param("userId") Long userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
}
